<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>  
<html>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta charset="utf-8">

<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame 
       Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<style type="text/css">
.loggedAs {
   font-weight: bold;
}

button {
	margin: 0 0.5em;
}

footer span {
	margin-right: 0.5em;
}

footer img {
	height: 30px;
}
</style>

<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript"></script>

<script type="text/javascript">

function onload(data) {
   var caller = dojo.fromJson(data)
   dojo.byId('loggedAs').innerHTML = caller.user.username
}

function _onerror(error) {
   alert(error)  
}

function init() {  
	dojo.xhrGet({ 
	      url: 'services/users',
	      load: onload,
	      error: _onerror})
}

function logout() {
	dojo.xhrDelete({ 
		url: 'services/users',
		load: init,
	    error: _onerror})
}

dojo.addOnLoad(init)
</script>

</head>

<body>
<h1>OAuth Demo</h1>
<p>Your are logged as: <span id='loggedAs' class='loggedAs'></span><span><button onclick='init(); return false'>Refresh</button></span></p>
<p>
Click <a href='login.html'>here</a> to authorize this application to access your Google account.
</p>
<p><a href='' onclick='logout(); return false'>Logout</a></p>
<footer>
	<p>
		<span><a href='http://code.google.com/p/simple-dm'><img src="images/sdm_logo.gif" alt="Powered by Simple Dynamic Modules" /></a></span>
		<span><img src="images/dojo_toolkit.png" alt="Powered by The Dojo Toolkit" /></span>
		<span><img src="http://code.google.com/appengine/images/appengine-silver-120x30.gif" alt="Powered by Google App Engine" /></span>
	</p>
</footer>
</body>
</html>
